package com.adam.example.util;

import java.util.List;
import java.util.Map;

public class CollectionStreamUtil {

    public static class CollectionStreamUtilInnerClass {
        private Object object;

        public CollectionStreamUtilInnerClass(Object object) {
            this.object = object;
        }

        public Map<String, Object> getMap() {
            return (Map<String, Object>) object;
        }

        public List<Map<String, Object>> getListMap() {
            return (List<Map<String, Object>>) object;
        }

        public <T> T get(Class<T> tClass) {
            return (T) object;
        }

        public CollectionStreamUtilInnerClass getKey(String key) {
            Map<String, Object> map = (Map<String, Object>) object;
            return new CollectionStreamUtilInnerClass(map.get(key));
        }

        public CollectionStreamUtilInnerClass getElement(int index) {
            List<Object> list = (List<Object>) object;
            return new CollectionStreamUtilInnerClass(list.get(index));
        }
    }

    public static CollectionStreamUtilInnerClass build(Map<String, Object> map) {
        return new CollectionStreamUtilInnerClass(map);
    }

}
